const cloud = require('wx-server-sdk')

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

// 获取openId云函数入口函数
exports.main = async (event, context) => {
  // 获取基础信息
  const wxContext = cloud.getWXContext()
  console.log(wxContext)
  try {
    const result = await cloud.openapi.riskControl.getUserRiskRank({
        "appid": wxContext.APPID,
        "openid": wxContext.OPENID,
        "scene": 1,
        "clientIp": wxContext.CLIENTIP
      })
    return result
  } catch (err) {
    return err
  }
}